import { createAction } from 'redux-actions';

export const actionTypes = {
  INIT_QUESTIONNAIRE: 'INIT_QUESTIONNAIRE',
  STOP_PAGE_LOADING: 'STOP_PAGE_LOADING',
  START_PAGE_LOADING: 'START_PAGE_LOADING',
  INIT_USER_UUID: 'INIT_USER_UUID',
  INIT_USER: 'INIT_USER',
  CLEAR_USER: 'CLEAR_USER',
  INIT_SCORE_LIST: 'INIT_SCORE_LIST',
  UPDATE_SCORE: 'UPDATE_SCORE',
  UPDATE_USER_PROP: 'UPDATE_USER_PROP',
  INIT_MERGE_UUID: 'INIT_MERGE_UUID',
  INIT_NEXT_EVENT: 'INIT_NEXT_EVENT'
};

export const initQuestionnaireAction = createAction<
  QA.QuestionnaireInitBaisc
>(actionTypes.INIT_QUESTIONNAIRE);
export const clearUserAction = createAction(actionTypes.CLEAR_USER);
export const startPageLoadingAction = createAction(
  actionTypes.START_PAGE_LOADING
);
export const stopPageLoadingAction = createAction(
  actionTypes.STOP_PAGE_LOADING
);
export const initUserUuidAction = createAction<string>(
  actionTypes.INIT_USER_UUID
);
export const initMergeUuidAction = createAction<string | undefined>(
  actionTypes.INIT_MERGE_UUID
);
export const updateScoreAction = createAction<{
  index: number, score?: number
}>(
  actionTypes.UPDATE_SCORE
);
export const initScoreListAction = createAction<
  { questionId: number, score?: number }[]
>(actionTypes.INIT_SCORE_LIST);
export const updateUserPropAction = createAction<
  { key: string, value: number | string }
>(actionTypes.UPDATE_USER_PROP);
export const initNextEvent = createAction(actionTypes.INIT_NEXT_EVENT);
